//
//  HomeCell.m
//  Manager
//
//  Created by 彭凯敏 on 15/8/17.
//  Copyright (c) 2015年 52xiaoluo. All rights reserved.
//

#import "RoomCell.h"

@implementation RoomCell




- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (IBAction)clickPhone:(UIButton *)sender {
    
    [KMCheckTel dialPhoneNumber:_cellOrder.phone withView:self.window];
    
    
}

- (void)setCellOrder:(ViewOrder *)cellOrder
{
    _cellOrder = cellOrder;
    
    _nameLabel.text = [cellOrder.name judgeWithBase:@""];
    
    if (cellOrder.status == 6||cellOrder.status == 7)
    {
        [self roomWith:@"签约" withtime:cellOrder.signTime];
    }
    else if (cellOrder.status == 5 || cellOrder.status == 4)
    {
        [self roomWith:@"约看" withtime:cellOrder.viewTime];
    }
    else if (cellOrder.status == 3) {
        [self roomWith:@"预约" withtime:cellOrder.orderTime];
    }

    
}

- (void)roomWith:(NSString *)textStr withtime:(UInt64)time
{
    _timeLabel.text = [NSString stringWithFormat:@"%@时间：%@",textStr,[KMGetDate timeFromNum:[NSString stringWithFormat:@"%llu",time/1000] andFormStr:@"YYYY-MM-dd HH:mm"]];
    
    if (!_cellOrder.viewRooms) {
        _roomLabel1.text = [NSString stringWithFormat:@"%@房间：无",textStr];
        _statusLabel.text = @"";
        
    }
    else
    {
        RoomInfo *info = _cellOrder.viewRooms[0];
        _roomLabel1.text = [info.name judgeRoomBase:[NSString stringWithFormat:@"%@房间：",textStr]];
        
        if ([textStr isEqualToString:@"签约"]) {
            _statusLabel.text = [UIViewCategory roomStatusWith:info];
        }
        else
        {
            _statusLabel.text = [UIViewCategory roomStatusWith:info];
        }
        
        
        if ([info.name isEqualToString:@""]) {
            _roomLabel1.text = [NSString stringWithFormat:@"%@房间：无",textStr];
            _statusLabel.text = @"";
        }
    }
}

@end
